<template>
  <div class="box" shadow="never">
    <el-form ref="form" :model="list" label-width="120px">

      <el-form-item label-width="100px" label="课程ID:" >
              <el-input v-model="list.course_id" style="width: 400px;" >
              </el-input>
            </el-form-item>

            <el-form-item label-width="100px" label="教师ID:" >
              <el-input v-model="list.teacher_id" style="width: 400px;" >
              </el-input>
            </el-form-item>

           <el-form-item label-width="100px" label="课程名称:" >
              <el-input v-model="list.name" style="width: 400px;" >
              </el-input>
            </el-form-item>


<!--
              <el-form-item label-width="100px" label="类型:">
                    <el-input v-model="list.type" style="width: 400px;" />
              </el-form-item>

               <el-form-item label-width="100px" label="标签:">
                    <el-input v-model="list.label" style="width: 400px;" />
              </el-form-item>

               <el-form-item label-width="100px" label="价格:">
                    <el-input v-model="list.price" style="width: 400px;" />
              </el-form-item>

               <el-form-item label-width="100px" label="公司简介:">
                    <el-input v-model="list.brief_introduction" style="width: 400px;" />
               </el-form-item>

               <el-form-item label-width="100px" label="课程介绍:">
                    <el-input v-model="list.introduction" style="width: 400px;" />
               </el-form-item>

               <el-form-item label-width="100px" label="开始时间:">
                    <el-input v-model="list.start_time" style="width: 400px;" />
              </el-form-item>

              <el-form-item label-width="100px" label="学习人数:">
                    <el-input v-model="list.study_number" style="width: 400px;" />
              </el-form-item> -->

      <el-form-item>
        <el-button type="primary" @click="onSubmit">添加</el-button>
        <!-- <el-button @click="onCancel">取消</el-button> -->
      </el-form-item>

    </el-form>

  </div>
</template>

<script>
export default {

  data() {
    return {
	 url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
      list: {

			  "course_id": 130,
        "name": "string",
        "teacher_id": 150,
        "type": "string",
        "label": "string",
        "cover_picture": "string",
        "price": 0,
        "brief_introduction": "string",
        "introduction": "string",
        "start_time": 1649576891,
        "study_number": 0,
        "star": 0,
        "status": 0,

      }
    }
  },

  methods: {

    onSubmit() {
      var vm = this
      this.axios({
        method: 'POST',
        url: 'http://172.21.136.71:8080/course',
       headers: {
			      'Authorization': 'eyJKV1QiOiJKV1QiLCJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NiwiaWF0IjoxNjQ0Mzk2NjkwLCJqdGkiOiJlZGJlYzE1Mzg5ZmQ0YmFhOThjYTg5ODIwYzMxOTBmNCJ9.yUp8dY-2pY4WB7zjnpWKHFZfHHc8e9neT5XuuzQ0_tg'
			    },
        data: vm.list
      }).then(function(resp) {
        // 添加成功后前往文章页面
        // vm.$router.push("/HealthyArticle")
        console.log('----------------------------');
        console.log(resp);
        vm.$router.go(-1)

        if (resp.data.errorCode == 0) {
        	vm.$message({
        	  message: '添加成功!',
        	  type: 'success'
          })
        }
      }).catch(function(error) {
        console.log('--------------------asdsa');
      			 vm.$message.error('添加失败')
      })
    }

  }
}
</script>

<style lang="scss" scoped>

.line{
  text-align: center;
}

.box{
  margin-left: 200px;
  height: 1100px;
  width: 700px;
  border:  solid rgb(187, 186, 187);
}
</style>



<template>
  <div class="box" shadow="never">
    <el-form ref="form" :model="adcourseSet" label-width="120px">

            <el-form-item label-width="100px" label="课程ID:" >
              <el-input v-model="adcourseSet.course_id" style="width: 400px;" >
              </el-input>
            </el-form-item>

            <el-form-item label-width="100px" label="教师ID:" >
              <el-input v-model="adcourseSet.teacher_id" style="width: 400px;" >
              </el-input>
            </el-form-item>

           <el-form-item label-width="100px" label="课程名称:" >
              <el-input v-model="adcourseSet.name" style="width: 400px;" >
              </el-input>
            </el-form-item>

              <el-form-item label-width="100px" label="类型:">
                    <el-input v-model="adcourseSet.type" style="width: 400px;" />
              </el-form-item>

               <el-form-item label-width="100px" label="标签:">
                    <el-input v-model="adcourseSet.label" style="width: 400px;" />
              </el-form-item>

               <el-form-item label-width="100px" label="价格:">
                    <el-input v-model="adcourseSet.price" style="width: 400px;" />
              </el-form-item>

               <el-form-item label-width="100px" label="公司简介:">
                    <el-input v-model="adcourseSet.brief_introduction" style="width: 400px;" />
               </el-form-item>

               <el-form-item label-width="100px" label="课程介绍:">
                    <el-input v-model="adcourseSet.introduction" style="width: 400px;" />
               </el-form-item>

               <el-form-item label-width="100px" label="开始时间:">
                    <el-input v-model="adcourseSet.start_time" style="width: 400px;" />
              </el-form-item>

              <el-form-item label-width="100px" label="学习人数:">
                    <el-input v-model="adcourseSet.study_number" style="width: 400px;" />
              </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">添加</el-button>
      </el-form-item>

    </el-form>

  </div>
</template>

<script>
import addhealcourse from '@/api/healthycourse'
export default {

  data() {
    return {
	 url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
      adcourseSet: {
        "course_id": 0,
        "name": "string",
        "teacher_id": 0,
        "type": "string",
        "label": "string",
        "cover_picture": "string",
        "price": 0,
        "brief_introduction": "string",
        "introduction": "string",
        "start_time": 1649583105,
        "study_number": 0,
        "star": 0,
        "status": 0,
      }
    }
  },

  methods: {
    onSubmit() {
      var vm = this
      addhealcourse.adcourse(vm.adcourseSet)
      .then(function(resp) {
        	this.$message({
        	  message: '添加成功!',
        	  type: 'success'
          })

        this.$router.go(-1)
      })
      .catch(function(error) {
        console.log('--------------------asdsa');
        console.log('asdsaddddd',this.adcourseSet);
      			 vm.$message.error('添加失败')
      })
    }

  }
}
</script>

<style lang="scss" scoped>

.line{
  text-align: center;
}

.box{
  margin-left: 200px;
  height: 1100px;
  width: 700px;
  border:  solid rgb(187, 186, 187);
}
</style>
